package com.jiepos.mpos.biz.channel.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.channel.service.CardBinService;
import com.jiepos.mpos.common.entity.App_Card_BinEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;


/**
 * 
 * 
 * <p>标题: —— 卡bin表控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.biz.channel.controller 
 * @author 张学涛
 * @version 1.0
 * @since 2017年9月26日下午2:23:48
 * @history（历次修订内容、修订人、修订时间等）
 */
@Controller
@RequestMapping("cardbin")
public class CardBinController extends BaseController {
	
	@Autowired
	private CardBinService cardBinService;

	/**
	 * 进入卡bin信息列表页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getCardBinList.do")
	public ModelAndView getCardBinList(HttpServletRequest request,HttpServletResponse response,Pagination pagination){
		ModelAndView model=new ModelAndView("/module/channel/cardbin/cardbin_list");
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 获取卡BIN列表
	 * @param pagination
	 * @param cardBin
	 * @return
	 */
	@RequestMapping("/getCardBinListJson.do")
	public @ResponseBody Map getCardBinListJson(Pagination pagination,App_Card_BinEntity cardBin){
		return cardBinService.getCardBinList(pagination, cardBin);		
	}
	
	/**
	 * 进入卡BIN信息详细页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @param card_bin_uuid
	 * @return
	 */
	@RequestMapping("/getCardBinDetail.do")
	public ModelAndView getCardBinDetail(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination,String card_bin_uuid){
		ModelAndView model=new ModelAndView("/module/channel/cardbin/cardbin_detail");
		App_Card_BinEntity cardBin=cardBinService.getCardBinById(card_bin_uuid);
		model.addObject("cardBin", cardBin);		
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 保存卡BIN
	 * @param request
	 * @param response
	 * @param cardBin
	 * @return
	 */
	@RequestMapping("/saveCardBin.do")
	public ModelAndView saveCardBin(HttpServletRequest request, HttpServletResponse response,App_Card_BinEntity cardBin){
		cardBinService.saveCardBin(cardBin, super.getLoginUser(request, response));
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getCardBinList.do"), map);
	}
	
	/**
	 * 删除卡BIN
	 * @param request
	 * @param response
	 * @param card_bin_uuids
	 * @return
	 */
	@RequestMapping("/deleteCardBinByIds.do")
	public ModelAndView deleteCardBinByIds(HttpServletRequest request, HttpServletResponse response,String card_bin_uuids){
		cardBinService.deleteCardBinByIds(card_bin_uuids);
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getCardBinList.do"), map);
	}
	
	/**
	 * 校验卡bin
	 * @param cardBin
	 * @return
	 */
	@RequestMapping("/checkCardBin.do")
	public @ResponseBody String checkCardBin(App_Card_BinEntity cardBin){		
		return cardBinService.checkCardBin(cardBin);
	}
}
